<?php

/**
 * Rayon form base class.
 *
 * @method Rayon getObject() Returns the current form's model object
 *
 * @package    appcemhti
 * @subpackage form
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseRayonForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_rayon'      => new sfWidgetFormInputHidden(),
      'id_element'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Element'), 'add_empty' => false)),
      'id_balayage'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Balayage'), 'add_empty' => true)),
      'id_traitement' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Faisceau'), 'add_empty' => false)),
      'isotope'       => new sfWidgetFormInputText(),
      'charge'        => new sfWidgetFormInputText(),
      'energie'       => new sfWidgetFormInputText(),
      'fluence'       => new sfWidgetFormInputText(),
      'courantmoy'    => new sfWidgetFormInputText(),
      'courantmax'    => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id_rayon'      => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_rayon')), 'empty_value' => $this->getObject()->get('id_rayon'), 'required' => false)),
      'id_element'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Element'))),
      'id_balayage'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Balayage'), 'required' => false)),
      'id_traitement' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Faisceau'))),
      'isotope'       => new sfValidatorInteger(array('required' => false)),
      'charge'        => new sfValidatorString(array('max_length' => 32, 'required' => false)),
      'energie'       => new sfValidatorNumber(array('required' => false)),
      'fluence'       => new sfValidatorNumber(array('required' => false)),
      'courantmoy'    => new sfValidatorNumber(array('required' => false)),
      'courantmax'    => new sfValidatorNumber(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('rayon[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Rayon';
  }

}
